Skip to content

Structured MCP filter schemas, hardened value enums, tool-description rewrite#315

Merged
HumanBean17 merged 3 commits into
masterfrom
feat/mcp-structured-filter-schemas
Jun 13, 2026
Merged

Structured MCP filter schemas, hardened value enums, tool-description rewrite#315
HumanBean17 merged 3 commits into
masterfrom
feat/mcp-structured-filter-schemas

Conversation

@HumanBean17

Copy link
Copy Markdown
Owner

Scope

Make the MCP filter surface structured and visible to clients, harden the
value taxonomies to enums, rewrite the tool descriptions, and close the
indexer-side validation holes that made two of those enums trustworthy.

Accumulated across a multi-session effort (no separate propose — incrementally
reviewed with the user); shipped as two logical commits.

Changes

  • Structured filter params (server.py, mcp_v2.py): search/find/neighbors
    filter and edge_filter are typed NodeFilter/EdgeFilter instead of
    opaque dict | str, so the tool input schema now exposes field-level types,
    enums, and descriptions ($ref NodeFilter / $ref EdgeFilter).
  • Hardened value enums (mcp_v2.py): role, framework, source_layer,
    client_kind, producer_kind are Literal enums (the last two newly closed).
  • Index-time validation (ast_java.py): the in-source
    @CodebaseHttpClient(clientKind=) / @CodebaseProducer(producerKind=) enum
    paths now validate against VALID_CLIENT_KINDS / VALID_PRODUCER_KINDS
    (warn + ignore on unknown), mirroring the existing YAML path. Deferred import
    to avoid the java_ontology → ast_java cycle. This is what makes
    client_kind/producer_kind a closed set safe to surface as enums.
  • VALID_ROLES / OTHER (java_ontology.py): added a comment documenting
    that OTHER is deliberately excluded — it is the inference-only fallback
    (read-side Role enum includes it; write-side VALID_ROLES does not). OTHER
    was not added to VALID_ROLES (would weaken @CodebaseRole/brownfield
    validation with no benefit).
  • Tool descriptions / _INSTRUCTIONS (server.py): dropped
    internal-implementation leaks, added sibling-tool cross-references, documented
    strict-frame failure modes (incl. the dedup_calls-without-CALLS silent
    no-op, hybrid+table='all'success=false).
  • apply_auto_scope (server.py): operates on NodeFilter (model_copy
    injection).

Behavior changes

  • BREAKING (MCP input schema): filter/edge_filter are now structured with
    extra="forbid". Unknown keys / bad enum values now fail at the FastMCP schema
    layer as a ToolError that names the bad field and lists the valid enum
    values
    (a net teaching improvement — the old success=false envelope never
    listed valid values for enum fields). Per-kind applicability and wildcard
    checks still return the in-function success=false envelope (with
    hints_structured). Direct v2 Python callers are unaffected (still accept
    dicts, still get the teaching envelope).
  • Indexing: invalid @CodebaseHttpClient(clientKind=…) /
    @CodebaseProducer(producerKind=…) values are now dropped (warned on stderr)
    instead of stored verbatim.

Reindex / ontology / env

  • No ontology_version bump — no graph schema/column change and no
    enrichment-semantic change.
  • Reindex recommended for indexes that captured out-of-set client/producer
    kinds under the old hole: that data remains in the graph but is no longer
    filterable via the new enum.
  • No env-var changes.

Validation

  • ruff check . clean
  • pytest tests769 passed, 11 skipped (11 skips pre-existing/env-gated;
    +2 new tests test_29a/test_29b covering the source-annotation validation)

🤖 Generated with Claude Code

HumanBean17 and others added 3 commits June 13, 2026 22:47
search/find/neighbors `filter`/`edge_filter` params are now typed
NodeFilter/EdgeFilter (structured, extra-forbidden) instead of opaque
dict|str, so MCP clients see field-level enums and descriptions. Value
taxonomies role/framework/source_layer/client_kind/producer_kind are Literal
enums. Rewrite the five tool descriptions and _INSTRUCTIONS to drop
internal-implementation leaks, cross-reference sibling tools, and document
strict-frame failure modes. apply_auto_scope operates on NodeFilter.

Co-Authored-By: Claude <noreply@anthropic.com>
The in-source @CodebaseHttpClient(clientKind=) / @CodebaseProducer(producerKind=)
enum paths did str(val) with no validation, unlike the YAML path. Validate
against VALID_CLIENT_KINDS/VALID_PRODUCER_KINDS (deferred import to avoid the
java_ontology->ast_java cycle) and warn-and-ignore on unknown — this closes the
last open producers, making client_kind/producer_kind a closed set safe to
surface as enums. Also document in java_ontology.py that VALID_ROLES deliberately
excludes OTHER (inference-only fallback; the read-side Role enum includes it).

Co-Authored-By: Claude <noreply@anthropic.com>
The structured filter schemas PR makes role/framework/source_layer/
client_kind/producer_kind closed Literal enums with extra="forbid", so
stale or omitted values are now hard schema errors instead of silent
no-ops. Align the three consumer-facing operating manuals with the
now-closed sets:

- Framework glossary: drop the non-existent `codebase_async_route` (only
  ever a function name, never a stored value), add the missing `feign`,
  drop the misleading `...` (the set is now closed/exhaustive).
- NodeFilter applicability tables: add `source_layer` to the client and
  producer rows (applicable per _NODEFILTER_APPLICABLE_FIELDS, previously
  undocumented).
- Strict-frame note: invalid enum values (e.g. wrong case) are rejected
  earlier at the schema layer with the valid set listed - distinct from
  the success=false applicability path.
- Glossary: add Source layers (client/producer) closed value set.

Doc-only; no code or test impact.

Co-Authored-By: Claude <noreply@anthropic.com>
@HumanBean17 HumanBean17 merged commit da99f74 into master Jun 13, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant